home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / rpc / rpcPacket.h < prev    next >
C/C++ Source or Header  |  1991-03-16  |  11KB  |  272 lines

  1. /*
  2.  * rpcPacket.h --
  3.  *
  4.  * This defines the RPC packet header format.  This header comes just
  5.  * after the packet transport header.  It contains information about the
  6.  * remote procedure call and is followed by parameters and data for the
  7.  * RPC.
  8.  *
  9.  * Copyright (C) 1987 Regents of the University of California
  10.  * All rights reserved.
  11.  * Permission to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose and without
  13.  * fee is hereby granted, provided that the above copyright
  14.  * notice appear in all copies.  The University of California
  15.  * makes no representations about the suitability of this
  16.  * software for any purpose.  It is provided "as is" without
  17.  * express or implied warranty.
  18.  *
  19.  * This packet format no longer agrees with the old-old sprite-unix
  20.  * hybrid (header "fsp.h")
  21.  *
  22.  * sccsid "Sprite $Header: /sprite/src/kernel/rpc/RCS/rpcPacket.h,v 9.8 90/12/03 18:21:10 kupfer Exp Locker: mgbaker $"
  23.  */
  24.  
  25. #ifndef _RPCPACKET
  26. #define _RPCPACKET
  27.  
  28. #ifdef KERNEL
  29. #include <rpcTypes.h>
  30. #else
  31. #include <kernel/rpcTypes.h>
  32. #endif /* KERNEL */
  33.  
  34. /*
  35.  * The Rpc header.
  36.  */
  37. typedef struct RpcHdr {
  38.     unsigned int    version;    /* This is a combined version number
  39.                      * and byte-order indicator.  See
  40.                      * the defines below. */
  41.     unsigned int    flags;        /* Protocol flags, explained below */
  42.     int            clientID;    /* Client Sprite host id */
  43.     int            serverID;    /* Server Sprite host id */
  44.     int            channel;    /* The client channel number */
  45.     int            serverHint;    /* Server index hint. The server
  46.                      * machine updates this on every
  47.                      * packet it sends to a client.  The
  48.                      * channel being used for the RPC
  49.                      * should preserve the value sent
  50.                      * and return it (in this field) with
  51.                      * future messages to the server */
  52.     unsigned int    bootID;        /* Client boot timestamp.  This changes
  53.                      * each time a host reboots. */
  54.     unsigned int    ID;        /* ID/sequence number. This ID is the
  55.                      * same on all packets pertaining
  56.                      * to the same RPC. This increases
  57.                      * until the origniating host reboots */
  58.     unsigned int    delay;        /* Interfragment delay info */
  59.     unsigned int    numFrags;    /* Number of fragments in packet (<=16).
  60.                      * If the packet is complete, ie. no
  61.                      * fragmenting, then this field should
  62.                      * be ZERO */
  63.     unsigned int    fragMask;    /* Fragment bitmask ID. The I'th frag
  64.                      * has the I'th bit of this mask
  65.                      * set.  If no fragments then this
  66.                      * field should be ZERO.  On partial
  67.                      * acknowledgments this contains
  68.                      * the receiver's summary bitmask */
  69.     int            command;    /* Rpc command (see rpcCall.h) or
  70.                      * error code if RPC_ERROR is set */
  71.     int            paramSize;    /* Size of the parameter area */
  72.     int            dataSize;    /* Size of the data data area */
  73.     int            paramOffset;    /* This is the starting offset for the
  74.                      * block of parameter bytes sent in
  75.                      * this fragment.  This is zero for
  76.                      * unfragmented sends and for the first
  77.                      * fragment of a group */
  78.     int            dataOffset;    /* Offset for the data area. */
  79. } RpcHdr;                /* 64 BYTES */
  80.  
  81. /*
  82.  * The following is the new format for rpc headers.  It has offsets for the
  83.  * start of the parameter and data areas, allowing the rpc packet to be
  84.  * padded.  This is useful if your network interface doesn't do 
  85.  * scatter/gather and you want to avoid copying the different rpc 
  86.  * pieces into contiguous memory.  Currently these new rpc headers
  87.  * are only used on the Ultranet.
  88.  */
  89.  
  90. typedef struct RpcNewHdr {
  91.     unsigned int    version;    /* This is a combined version number
  92.                      * and byte-order indicator.  See
  93.                      * the defines below. */
  94.     unsigned int    flags;        /* Protocol flags, explained below */
  95.     int            clientID;    /* Client Sprite host id */
  96.     int            serverID;    /* Server Sprite host id */
  97.     int            channel;    /* The client channel number */
  98.     int            serverHint;    /* Server index hint. The server
  99.                      * machine updates this on every
  100.                      * packet it sends to a client.  The
  101.                      * channel being used for the RPC
  102.                      * should preserve the value sent
  103.                      * and return it (in this field) with
  104.                      * future messages to the server */
  105.     unsigned int    bootID;        /* Client boot timestamp.  This changes
  106.                      * each time a host reboots. */
  107.     unsigned int    ID;        /* ID/sequence number. This ID is the
  108.                      * same on all packets pertaining
  109.                      * to the same RPC. This increases
  110.                      * until the origniating host reboots */
  111.     unsigned int    delay;        /* Interfragment delay info */
  112.     unsigned int    numFrags;    /* Number of fragments in packet (<=16).
  113.                      * If the packet is complete, ie. no
  114.                      * fragmenting, then this field should
  115.                      * be ZERO */
  116.     unsigned int    fragMask;    /* Fragment bitmask ID. The I'th frag
  117.                      * has the I'th bit of this mask
  118.                      * set.  If no fragments then this
  119.                      * field should be ZERO.  On partial
  120.                      * acknowledgments this contains
  121.                      * the receiver's summary bitmask */
  122.     int            command;    /* Rpc command (see rpcCall.h) or
  123.                      * error code if RPC_ERROR is set */
  124.     int            paramSize;    /* Size of the parameter area */
  125.     int            dataSize;    /* Size of the data data area */
  126.     int            paramOffset;    /* This is the starting offset for the
  127.                      * block of parameter bytes sent in
  128.                      * this fragment.  This is zero for
  129.                      * unfragmented sends and for the first
  130.                      * fragment of a group */
  131.     int            dataOffset;    /* Offset for the data area. */
  132.     int            paramStart;    /* Start of param area in bytes from
  133.                      * start of the RpcHdr. */
  134.     int            dataStart;    /* Start of data area in bytes from
  135.                      * start of the RpcHdr. */
  136. } RpcHdrNew;                /* 72 BYTES */
  137.  
  138. /*
  139.  * Version number / byte-ordering word.
  140.  *    RPC_NATIVE_VERSION    Version number in native format
  141.  *    RPC_SWAPPED_VERSION    Version number if originating on a Vax byte
  142.  *                ordered host and read on a MC680xx host,
  143.  *                or vice versa.
  144.  *    To change the version number increment the right-most byte
  145.  *    in the native version.
  146.  */
  147.  
  148. /*
  149.  *    Version 1:    6-13-88        Original.
  150.  *    Version 2:    6-19-88        For cleaning up parameters in
  151.  *                    preparation for byte-swapping.
  152.  *    Version 3:    6-8-89        New FS parameters.  New ethernet
  153.  *                    packet type (not 0x500 !!)
  154.  */
  155. #define    RPC_NATIVE_VERSION    0x0f0e0003
  156. #define RPC_SWAPPED_VERSION    0x03000e0f
  157. #define    RPC_NATIVE_VERSION_NEW    0xfeedface
  158. #define RPC_SWAPPED_VERSION_NEW    0xcefaedfe
  159.  
  160. /*
  161.  * These are the version variables actually used in the kernel. You can
  162.  * change them early in the boot if you want a different version number.
  163.  */
  164.  
  165. extern int     rpc_NativeVersion;
  166. extern int    rpc_SwappedVersion;
  167. extern int     rpc_NativeVersionNew;
  168. extern int    rpc_SwappedVersionNew;
  169.  
  170. /*
  171.  * The flags field is used to type packets and for flags that
  172.  * modify the packet type.
  173.  *
  174.  * Packet Types:
  175.  *    RPC_REQUEST a request message sent by the client to the server.
  176.  *
  177.  *    RPC_REPLY a reply message returned to the client from the server.
  178.  *
  179.  *    RPC_ACK an explicit acknowledgment message for a request or reply.
  180.  *    If the RPC_LASTFRAG flag is present then this is a partial
  181.  *    acknowledgment and the summary bitmask is in the fragMask field.
  182.  *
  183.  *    RPC_ECHO a special packet that just is bounced off the server by
  184.  *    the dispatcher.  A server process is not involved.
  185.  *
  186.  *    RPC_NACK a negative acknowledgement from the server saying that it's
  187.  *    alive, but can't handle the request yet (no server process for it, etc).
  188.  *
  189.  * Packet Flags:
  190.  *    RPC_PLSACK demands an explicit acknowledgment message from the receiver.
  191.  *
  192.  *    RPC_LASTFRAG is present on the last fragment of a batch being sent,
  193.  *    which is not always the last fragment in a message because a partial
  194.  *    partial re-send may only involve some fragments in the middle
  195.  *    of the message.  This flag set on partial acknowledgments.
  196.  *
  197.  *    RPC_CLOSE only valid on type RPC_ACK messages.  This means the server
  198.  *    is requesting acknowledgement of its last reply so it can reassign
  199.  *    the server process to an active client channel.  When combined with
  200.  *    RPC_SERVER, this means the client has successfully gotten its
  201.  *    last reply.
  202.  *
  203.  *    RPC_ERROR indicates the service routine had an error, in this
  204.  *    case the command field contains an error code.
  205.  *
  206.  *    RPC_NOT_ACTIVE means that the originating host is not fully alive.
  207.  *    This means the packet is ignored by the recovery module, but still good.
  208.  *
  209.  * Flags only valid in trace records:
  210.  *    RPC_SERVER the packet is bound for the server side of the rpc system.
  211.  *
  212.  *    RPC_LAST_REC the trace record is the oldest trace record in the
  213.  *    circular buffer.
  214.  */
  215. #define RPC_NO_FLAGS    0x0
  216. #define RPC_FLAG    0x00ff
  217. #define RPC_PLSACK    0x0001
  218. #define RPC_LASTFRAG    0x0002
  219. #define RPC_CLOSE    0x0004
  220. #define RPC_ERROR    0x0008
  221. #define RPC_SERVER    0x0010
  222. #define RPC_LAST_REC    0x0020
  223. #define RPC_NOT_ACTIVE    0x0040
  224.  
  225. #define RPC_TYPE    0xff00
  226. #define RPC_REQUEST    0x0100
  227. #define RPC_ACK        0x0200
  228. #define RPC_REPLY    0x0400
  229. #define RPC_ECHO    0x0800
  230. #define    RPC_NACK    0x1000
  231.  
  232. /*
  233.  * Items related to Fragmenting.
  234.  *
  235.  * The maximum size supported by fragmentation is 16K of data plus
  236.  * 1k of parameters.  This large chunk is broken into fragments.
  237.  * The maximum size of a datagram is dependent on the transport medium.
  238.  */
  239. #define RPC_MAX_NUM_FRAGS    16
  240. #define RPC_MAX_FRAG_SIZE    1024
  241. #define RPC_MAX_DATASIZE    (RPC_MAX_NUM_FRAGS * RPC_MAX_FRAG_SIZE)
  242. #define RPC_MAX_PARAMSIZE    (1 * RPC_MAX_FRAG_SIZE)
  243. #define RPC_MAX_SIZE        (RPC_MAX_DATASIZE+RPC_MAX_PARAMSIZE)
  244.  
  245. /*
  246.  * An array of bitmasks is kept so the dispatcher can quickly determine if
  247.  * a message is complete.  Indexed by the total number of fragments in the
  248.  * packet, the array contains a complete bitmask for that many fragments.
  249.  */
  250. extern unsigned int rpcCompleteMask[];
  251.  
  252. /*
  253.  * Machines have some minimum delay that they can handle between successive
  254.  * packets before they start to drop them.  The current notion of this delay
  255.  * for other hosts is kept in rpcDelay.  This machine's currently acceptable
  256.  * delay is kept in rpcMyDelay, while its max speed at generating packets is
  257.  * kept in rpcOutputRate.  This information is used to insert, if neccesary,
  258.  * delays between transmission of fragments.
  259.  */
  260. extern short rpcDelay[];        /* Other host's inter-frag delay */
  261. extern unsigned short rpcMyDelay;    /* This host's inter-frag delay */
  262. extern unsigned short rpcOutputRate;        /* This machines output rate */
  263.  
  264. /*
  265.  * Forward Declarations.
  266.  */
  267. extern ReturnStatus RpcOutput _ARGS_((int spriteID, register RpcHdr *rpcHdrPtr, RpcBufferSet *message, RpcBufferSet *fragment, unsigned int dontSendMask, Sync_Semaphore *mutexPtr));
  268.  
  269. extern void RpcGetMachineDelay _ARGS_((unsigned short *myDelayPtr, unsigned short *outputRatePtr));
  270.  
  271. #endif /* not _RPCPACKET */
  272.